package com.example.mybatislearn.common.mapper;


import com.example.mybatislearn.common.mapper.exception.SmartMapperException;
import org.dozer.loader.DozerBuilder;
import org.dozer.loader.api.BeanMappingBuilder;

import java.lang.reflect.Field;

public abstract class SmartBeanMappingBuilder extends BeanMappingBuilder {


    //对外暴露config
    protected DozerBuilder getDozerBuilder() throws SmartMapperException {
        try {

            Field dozerBuilder =
                    this.getClass().getSuperclass().getSuperclass().getDeclaredField("dozerBuilder");
            dozerBuilder.setAccessible(true);
            return (DozerBuilder) dozerBuilder.get(this);
        }catch (Exception e) {
            throw new SmartMapperException(e.getMessage(),e);
        }
    }

}
